<template>
  <div>
    <el-form :model="form" :rules="rules" ref="form">
      <el-form-item label="包材编码" prop="code">
        <el-input v-model="form.code" style='width:75%'></el-input>
      </el-form-item>
      <el-form-item label="包材名称" prop="name">
        <el-input v-model="form.name" style='width:75%'></el-input>
      </el-form-item>
      <el-form-item label="包材容积" prop="volume">
        <el-input-number v-model="form.volume" :min='0' style='width:75%'></el-input-number>
      </el-form-item>
    </el-form>
    <el-button @click='sub' style='margin-top:10px;margin-left:80%'>保存</el-button>
  </div>
</template>
<script>
// import { packingMaterialAdd } from '@/api/packingMaterial/packingMaterial'
import request from '@/utils/request'
export default {
  data(){
    return{
      form:{},
      rules:{
        volume:[{ required: true, message: '请输入包材容积', trigger: 'blur' }],
        code:[{ required: true, message: '请输入包材编码', trigger: 'blur' }],
        name:[{ required: true, message: '请输入包材名称', trigger: 'blur' }]
      }
    }
  },
  created(){},
  methods:{
    sub(){
      this.$refs['form'].validate((valid) => {
        if(valid){
          let data = this.form
          request({
            url: '/wms/packingMaterial',
            method: 'post',
            data
          }).then(res=>{
            this.$message.success(res.msg)
            this.$emit('concen');
          })
        }
      })
    }
  }
}
</script>
